package cn.myjerry.net.tcp.socket;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * 1、创建客户端 + 必须指定服务器 + 端口 此时就在接受数据
 * 2、接收数据 + 发送数据
 * @author zpon
 *
 */
public class Client {
	public static void main(String[] args) throws UnknownHostException, IOException {
		Socket client = new Socket("localhost", 8888);
		
		/*
		BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream()));
		
		String str = br.readLine();
		System.out.println(str);
		*/
		
		DataInputStream dis = new DataInputStream(client.getInputStream());
		String str = dis.readUTF();
		System.out.println(str);
	}
}
